<template>
  <div>
    <h1 class="div-head">邮箱激活</h1>
    <Result
      v-if="show"
      type="success"
      isSuccess="success"
      title="激活成功"
      description="请点击按钮到登录页面"
      class="result"
    ></Result>
    <Result v-if="!show" title="激活失败" class="result"></Result>
    <h3 v-if="!show" class="h3-head">激活失败,请点击按钮重新发送邮件</h3>
    <div v-if="show" style="text-align:center;">
      <a-button type="primary" @click="goLogin">立即登录</a-button>
    </div>
    <div v-if="!show" style="text-align:center;">
      <a-button type="primary" :loading='loading' @click="sendAgain">重新发送邮件</a-button>
    </div>
  </div>
</template>
<script>
import Result from "@/components/result/Result";

export default {
  components: {
    Result
  },
  data() {
    return {
      show: false,
      loading:false
    };
  },
  created() {
    this.emailres();
  },
  methods: {
    emailres() {
      console.log("12344");
      console.log(this.$route);
      this.$axios
        .get(
          "/member/reg/email/act/" +
            this.$route.params.id +
            "/" +
            this.$route.params.num
        )
        .then(res => {
          console.log("res", res);
          if (res.data.code == "OK") {
            this.show = true;
          } else {
            this.show = false;
          }
          console.log(this.show);
        });
    },
    goLogin() {
      this.$router.push({ path: "/home" });
    },
    sendAgain() {
      console.log("再次发送激活邮件");
      this.loading = true;
      let data = {
        memberNo: this.$route.params.id
      }
      this.$axios.post('/agent/member/reg/reEmail/act',data).then(res => {
          console.log('res', res);
          if (res.data.code == 'OK') {
            this.loading = false;
            let type = "success";
            this.$notification[type]({
              message: "邮件已发送",
              description: "请登录邮箱查看。"
            });
          } else {
            this.$message.error(res.data.message)
          }
        })
    },
    doNext(step) {
      console.log(step);
      var st = step + 1;
      this.$router.push("/OrgRegister/step" + st);
    }
  }
};
</script>
<style scoped>
.div-head {
  text-align: center;
  padding: 100px 0 100px 0;
}
.h3-head {
  text-align: center;
  padding: 0px 0 30px 0;
}
</style>


